import urllib.parse
import urllib.request

url = 'http://httpbin.org/post'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
                  'Chrome/58.0.3029.110 Safari/537.3'
}

data = {
    'key1': 'value1',
    'key2': 'value2'
}

data = urllib.parse.urlencode(data).encode('utf-8')

req = urllib.request.Request(url, data=data, headers=headers, method='POST')

response = urllib.request.urlopen(req)
result = response.read().decode('utf-8')
print(result)
